﻿<UserControl x:Name="_root"
	x:Class="WPFCABShell.Shell.Visualizers.LogVisualizer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:diag="clr-namespace:WPFCABShell.Shell.Interface.Diagnostics;assembly=WPFCABShell.Shell.Interface"
	xmlns:local="clr-namespace:WPFCABShell.Shell.Visualizers"
	xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
	xmlns:con="http://schemas.kent.boogaart.com/converters">
	<Grid DataContext="{Binding ElementName=_root}">
		<Grid.Resources>
			<CollectionViewSource x:Key="Logs" Source="{Binding Logs}">
				<CollectionViewSource.SortDescriptions>
					<scm:SortDescription PropertyName="Name"/>
				</CollectionViewSource.SortDescriptions>
			</CollectionViewSource>
		</Grid.Resources>
		
		<Grid.RowDefinitions>
			<RowDefinition Height="*"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
		</Grid.ColumnDefinitions>

		<Grid>
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="*"/>
			</Grid.RowDefinitions>
			<Label>Logs:</Label>
			<ListView x:Name="_logsListView" Grid.Row="1" ItemsSource="{Binding Source={StaticResource Logs}}">
				<ListView.View>
					<GridView>
						<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Name" Width="Auto"/>
						<GridViewColumn x:Name="_logLevelColumn" Header="Log Level" Width="Auto">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<ComboBox ItemsSource="{Binding AllLogLevels, ElementName=_root}" SelectedItem="{Binding DataContext, RelativeSource={RelativeSource Self}, Converter={StaticResource LogLevelConverter}, Mode=OneTime}" SelectionChanged="_logLevelComboBox_SelectionChanged"/>
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
					</GridView>
				</ListView.View>
			</ListView>
		</Grid>
		
		<GridSplitter Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Height="3"/>

		<Grid Grid.Row="2">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="*"/>
			</Grid.RowDefinitions>
			
			<Label>Log Output:</Label>
			<TextBox x:Name="_outputTextBox" Grid.Row="1" IsReadOnly="True" FontFamily="Consolas,Courier New" FontSize="12" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"/>
		</Grid>
		
		<StackPanel Grid.Row="3" Orientation="Horizontal">
			<CheckBox IsChecked="{Binding AutoScroll}">Auto-scroll</CheckBox>
			<Button Click="_clearButton_Click">_Clear</Button>
		</StackPanel>
	</Grid>
</UserControl>
